package com.shengzai;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;

public class Code1WorldCountJava {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new FileReader("hadoop_code/src/data/worlds.txt"));
        HashMap<String, Integer> mapWorld = new HashMap<>();
        String lines = "";
        while ((lines=bufferedReader.readLine()) !=null){
            String[] split = lines.split(" ");
            for (String s : split) {
                if (mapWorld.containsKey(s)){
                    mapWorld.put(s,mapWorld.get(s).intValue()+1);
                } else {
                    mapWorld.put(s,1);
                }

            }
        }
        System.out.println(mapWorld);
        bufferedReader.close();



    }
}
